<?php
include_once("includes/global.php");
include_once("includes/smarty_config.php");
//$sql = "select * from ".DISTRICT." where pid = '0' ";
//$db->query($sql);
//$city_list = $db->getRows();
//foreach($city_list as $key => $val){
//	$city_list[$key]['name'] = str_replace("市","",$val['name']);
//	if(!in_array($val['id'],[1,2,9,22])){
//		$sub_sql = "select * from ".DISTRICT." where pid = '{$val['id']}' ";
//		$db->query($sub_sql);
//		$city_list[$key]['sub'] = $db->getRows();
//		foreach($city_list[$key]['sub'] as $kk => $vv ){
//			$city_list[$key]['sub'][$kk]['name'] = str_replace("市","",$vv['name']);
//		}
//	} else {
//		$city_list[$key]['sub'] = '';
//	}
//
//}
//
//$tpl->assign("city_list",$city_list);

//=============================================城市分站 start==========================================
$domain_sql = "select * from ".DOMAIN." where isopen = '1' ";
$db->query($domain_sql);
$domain_city = $db->getRows();
$all_city = [];
foreach($domain_city as $key => $val) {
	$city = !empty($val['con2']) ? $val['con2'] : $val['con'];
	$city_sql = "select * from ".DISTRICT." where name like '%$city%' ";
	$db->query($city_sql);
	$city_info = $db->fetchRow();
	$all_city[$city_info['id']] = str_replace("市","",$city_info['name']);
}

$tpl->assign("all_city",$all_city);
//=============================================城市分站 end==========================================

$tpl->display("city_list.htm");
?>